{extends file="../acp.html"}

{block name="title"}{$head_title}{/block}
{block name="content"}
<div class="t-art" style="margin-bottom:10px;"><a href="/AcpSiteDeploy/add_site_deploy_activity" class="btn btn-blue"><i class="gicon-plus white"></i>添加活动</a>  </div>
<div class="tablesWrap">  
    <div class="tables-searchbox"> 
	<form name="form1" action="" method="get">
        <div class="t-list">
            <span class="tbs-txt">活动名称：</span>
            <input type="text" name="site_deploy_name" id="site_deploy_name" value="{$site_deploy_name}">
            <button class="btn" type="submit"><i class="gicon-search"></i>搜索</button>
        </div>
        <!--<div class="t-list">-->
            <!--<span class="tbs-txt">文章分类：</span>  -->
            <!--<select class="small" name="sort_id" id="sort_id">  -->
                <!--<option value="0">&#45;&#45;请选择&#45;&#45;</option> -->
				<!--{html_options options=$article_category_options selected=$article_category_option_selected}-->
            <!--</select>-->
        <!--</div>  -->
        <!--<div class="t-list t-list-w">-->
            <!--<div class="formitems inline">  -->
                <!--<label class="fi-name" style="width:40px; font-weight:normal;">时间：</label>  -->
                <!--<div class="form-controls" style="margin-left:40px;">  -->
                    <!--<input type="text" name="begin_time" id="begin_time" value="{$begin_time}" autocomplete="off" class="Wdate" onclick="WdatePicker({ dateFmt:'yyyy-MM-dd'})">  -->
                    <!--<span class="fi-text">至</span>  -->
                    <!--<input type="text" name="end_time" id="end_time" value="{$end_time}" autocomplete="off" class="Wdate" onclick="WdatePicker({ dateFmt:'yyyy-MM-dd'})">  -->
                <!--</div>  -->
            <!--</div> -->
        <!--</div> -->

	</form>
    </div>  
    <!-- end tables-searchbox -->  
    <table class="wxtables">  
        <colgroup>  
        <col width="5%">  
        <col width="10%">
        <col width="10%">
        <col width="10%">
        </colgroup>  
        <thead>  
            <tr>  
                <td>选择</td>  
                <td>活动名称</td>
                <td>图片</td>
                <td>操作</td>  
            </tr>  
        </thead>  
        <tbody>  
		{if $site_deploy_list}
		{foreach from=$site_deploy_list item=this}
            <tr>  
                <td class="_checkbox">  
                    <input type="checkbox" class="checkbox" name="a[]" value="{$this.site_deploy_id}">
                </td>
                <td>{$this.site_deploy_name}</td>
                <td class="serial">
					<img src="{$this.site_deploy_pic}"style="width:70px;height:50px;display:block;"/>
				</td>   
                <td>  
                    <a href="__APP__/AcpSiteDeploy/edit_site_deploy_activity/site_deploy_id/{$this.site_deploy_id}" class="btn" title="编辑"><i class="gicon-edit black"></i>编辑</a>
                    <a href="javascript:;" onclick="delete_obj({$this.site_deploy_id});" class="btn" title="删除"><i class="gicon-trash black"></i>删除</a>
                </td>  
            </tr>  
		{/foreach}
		{else}
			<tr>
				<td colspan="7" class="center">暂无活动，您可以<a href="__APP__/AcpSiteDeploy/add_site_deploy_activity">添加活动</a></td>
			</tr>
		{/if}
        </tbody>  
    </table>  
    <!-- end wxtables -->  
	{if $site_deploy_list}
    <div class="tables-btmctrl clearfix">  
        <div class="fl">  
            <a href="javascript:Select()" class="btn btn-blue">全选</a>
            <a href="javascript:Cancel()" class="btn btn-blue">取消</a>
            <a href="javascript:;" onclick="Batch_delete_obj();" class="btn btn-blue">删除</a>
        </div>  
        <div class="fr">  
            <div class="paginate">  
                {$page_str}
            </div>  
            <!-- end paginate -->  
        </div>  
    </div>  
	{/if}
    <!-- end tables-btmctrl -->  
</div>  
<!-- end tablesWrap -->    
{/block} 

{block name="js"}
<script src="/Public/Plugins/My97DatePicker/WdatePicker.js?version={$version}"></script>
<script>
    //全选
    function Select(){
        var sel=document.getElementsByName("a[]");
        for(var i=0;i<sel.length;i++){
            sel[i].checked=true;
        }
    }
    //取消全选
    function Cancel(){
        var sel=document.getElementsByName("a[]");
        for(var i=0;i<sel.length;i++){
            sel[i].checked=false;
        }
    }
</script>
{literal}
<script>
    function delete_obj(obj_id) {
        $.jPops.confirm(
                {
                    title: "提示",
                    content: "您确定要删除这条数据吗？",
                    okBtnTxt: "确定",
                    cancelBtnTxt: "取消",
                    callback: function (r) {
                        if (r) {
                            $.post('/AcpSiteDeploy/delete_deploy_activity', {"obj_id": obj_id}, function (data, textStatus) {
                                if (data == 'success') {
                                    alert('恭喜您，删除成功！');
                                    location.reload();
                                }
                                else {
                                    alert('对不起，删除失败！');
                                }
                            });
                        }
                        return true;
                    }
                });
    }


    function Batch_delete_obj() {
        $.jPops.confirm(
                {
                    title: "提示",
                    content: "您确定要删除这些数据吗？",
                    okBtnTxt: "确定",
                    cancelBtnTxt: "取消",
                    callback: function (r) {
                        if (r) {
                            var obj_ids = '';
                            var count = 0;
                            $('input[name="a[]"]:checked').each(function () {
                                count++;
                                obj_ids += $(this).val() + ',';
                            });

                            if (!count) {
                                alert('对不起，请选择至少一项进行删除！');
                                return;
                            }

                            obj_ids = obj_ids.substr(0, obj_ids.length - 1);

                            $.post('/AcpSiteDeploy/batch_delete_deploy_activity', {"obj_ids": obj_ids}, function (data, textStatus) {
                                if (data == 'success') {
                                    alert('恭喜您，删除成功！');
                                    location.reload();
                                }
                                else {
                                    alert('对不起，删除失败！');
                                }
                            });
                        }
                        return true;
                    }
                });
    }


</script>
{/literal}



{/block} 

